function animate(duration, start, end, callback, onEnd) {
  var startTime = new Date().getTime();
  var startVal = start;
  var endVal = end;
  var change = endVal - startVal;
  var timer = setInterval(function () {
    var nowTime = new Date().getTime();
    var elapsed = nowTime - startTime;
    var val = Math.round(ease(elapsed, startVal, change, duration));
    callback(val);
    if (elapsed >= duration) {
      clearInterval(timer);
      onEnd();
    }
  }, 10);
}
function ease(t, b, c, d) {
  t /= d / 2;
  if (t < 1) return (c / 2) * t * t + b;
  t--;
  return (-c / 2) * (t * (t - 2) - 1) + b;
}
export { animate };
